package team.se.tms.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import team.se.tms.dao.Dao;
import team.se.tms.dto.MenuDetail;
import team.se.tms.dto.Page;
import team.se.tms.dto.ParameterMap;
import team.se.tms.dto.ParameterPage;
import team.se.tms.po.MenuInfo;
import team.se.tms.service.MenuInfoService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 菜单信息业务层，具体实现菜单信息业务接口层定义的方法
 *
 * @author winkyle
 * @date 2018/11/18
 */
@Slf4j
@Service("MenuInfoServiceImpl")
public class MenuInfoServiceImpl extends BaseServiceImpl implements MenuInfoService{
    @Autowired
    private Dao dao;
    /**
     * 获取全部菜单信息
     *
     * @param page 分页
     * @return 菜单列表
     * @throws Exception 异常
     * @create on 2018/11/18 by winkyle
     */
    @Override
    public List<MenuInfo> listMenuInfos(Page page) throws Exception {
        boolean sort = true;
        if(page != null){
            sort = false;
        }
        return dao.selectList("MenuInfoMapper.selectMenuInfos",getParameterPage(page,"sort",sort));
    }

    /**
     * 获取全部菜单信息，子菜单为父菜单的属性
     *
     * @param menuType 菜单类型
     * @return 菜单列表
     * @throws Exception 异常
     * @create on 2018/11/18 by winkyle
     */
    @Override
    public List<MenuDetail> listMenuDetails(String menuType) throws Exception {
        return dao.selectList("MenuInfoMapper.selectMenuDetailsByMenuType",getParameterMap("menuType",menuType));
    }
}
